package com.ylm.smsservice.service.impl;

import com.ylm.smsservice.service.SmsService;
import com.ylm.smsservice.utils.SMSUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SmsServiceImpl implements SmsService {
    @Override
    public boolean sendSmsPhone(String phone, Map<String, String> map) {
        // 手机号为空，则不发送验证码
        if (StringUtils.isEmpty(phone))
            return false;
        try {
            SMSUtils.sendShortMessage(phone, map.get("code"));
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
